/******************************************************************************
*    Copyright (C), 2022 by D2X studio. All rights reserved.                  *
*                                                                             *
*    @file:      framework.h
*    @owner:     zhengjian.xie@gmail.com                                      *
*    @desc:                                                                   *
*    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +    *
* history:                                                                    *
*  <author>      <time>      <version>              <description>             *
*  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  *
*  |  Xzj |  20220411[23:47] | 1.0.0 |                  build              |  *
*  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  *
******************************************************************************/
#ifndef __framework_h__
#define __framework_h__

/** variant defne */
typedef unsigned char bool;
#define yes 1
#define no  0
#define nil NULL
typedef unsigned char uint8_t;
typedef   signed char  int8_t;

/** event structure define */
typedef struct {
    int  fd;
    bool is_eventfd;
    void (*doEvent)(void*);
} stEvent, *pstEvent;

/** timer structure define */
typedef struct {
    int  interval;
    int  duration;
    bool cycle;
    void (*doTimer)(void);
} stTimer, *pstTimer;

/** framework function declare */
void app_init(void);
void app_loop(void);
void app_exit(void);
void app_tick(void);

void app_event_add(pstEvent pEvt);
void app_event_del(pstEvent pEvt);
void app_event_init(pstEvent pEvt);
void app_event_deinit(pstEvent pEvt);
void app_event_set(pstEvent pEvt);
void app_event_reset(pstEvent pEvt);

void app_timer_add(pstTimer pTimer);
void app_timer_del(pstTimer pTimer);

#endif // __framework_h__
